package com.cmcc.aregister.ui.activity;

import java.util.Map;

import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import com.cmcc.aregister.R;
import com.cmcc.aregister.cs.constant.Arguments;
import com.cmcc.aregister.cs.constant.ConfigUtilHelper;
import com.cmcc.aregister.cs.util.PotoalParcelable;

public class PersonalInfoActivity extends ParentActivity {
    private final String TAG = "PersonalInfoActivity";
    private String name = "";
    private int sex;
    private String birth = "";
    private String card = "";
    private String socialCard = "";
    private TextView view1, view2, view3, view4, view5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init(R.layout.p_personal_info);
    }

    @Override
    protected void setupData() {
        if (getIntent().getParcelableExtra(Arguments.INTENT_TO_NEXT_PAGE) != null) {
            Map<String, Object> httpMap = ((PotoalParcelable) getIntent()
                .getParcelableExtra(Arguments.INTENT_TO_NEXT_PAGE)).map;
            name = (String) httpMap.get("name");
            sex = Integer.valueOf((String) httpMap.get("sex"));
            birth = (String) httpMap.get("birth");
            card = (String) httpMap.get("card");
            socialCard = (String) httpMap.get("socialCard");
            if (socialCard.equals("null") || socialCard == null) {
                socialCard = "";
            }
        }
    }

    @Override
    protected void setupView() {
        ((ImageView) findViewById(R.id.title))
            .setBackgroundResource(R.drawable.personal_info_title);
        view1 = (TextView) findViewById(R.id.name_txt);
        view2 = (TextView) findViewById(R.id.sex_txt);
        view3 = (TextView) findViewById(R.id.birth_txt);
        view4 = (TextView) findViewById(R.id.dlg_card_txt);
        view5 = (TextView) findViewById(R.id.social_num_txt);
    }

    @Override
    protected void onResume() {
        super.onResume();
        view1.setText(name);
        view2.setText(sex == 0 ? "男" : "女");
        view3.setText(birth);
        view4.setText(card);
        view5.setText(socialCard);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (ConfigUtilHelper.debug) {
            Log.i(TAG, "------onDestroy------");
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (ConfigUtilHelper.debug) {
            Log.i(TAG, "------onPause------");
        }
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        if (ConfigUtilHelper.debug) {
            Log.i(TAG, "------onRestart------");
        }
    }
}